<?php
/**
 * @copyright Copyright (C) 2010 redCOMPONENT.com. All rights reserved.
 * @license GNU/GPL, see license.txt or http://www.gnu.org/copyleft/gpl.html
 * Developed by email@recomponent.com - redCOMPONENT.com
 *
 * redSHOP can be downloaded from www.redcomponent.com
 * redSHOP is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License 2
 * as published by the Free Software Foundation.
 *
 * You should have received a copy of the GNU General Public License
 * along with redSHOP; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
// no direct access
defined('_JEXEC') or die('Restricted access');
$option=JRequest::getVar('option');

$show_with_vat = trim( $params->get( 'show_with_vat',0) );
$button_text = trim( $params->get( 'button_text','') );
$show_shipping_line = ( $params->get( 'show_shipping_line',0) );

$document = JFactory::getDocument();
$document->addStyleSheet("modules/mod_redshop_cart/css/cart.css");
require_once(JPATH_SITE.DS.'components'.DS.'com_redshop'.DS.'helpers'.DS.'product.php');
require_once(JPATH_SITE.DS.'components'.DS.'com_redshop'.DS.'helpers'.DS.'helper.php');
require_once(JPATH_SITE.DS.'components'.DS.'com_redshop'.DS.'helpers'.DS.'cart.php');

if($option!='com_redshop')
{
	require_once(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_redshop'.DS.'helpers'.DS.'redshop.cfg.php');
	require_once( JPATH_ADMINISTRATOR.DS.'components'.DS.'com_redshop'.DS.'helpers'.DS.'configuration.php' );
	$Redconfiguration = new Redconfiguration();
	$Redconfiguration->defineDynamicVars();
}

$show_empty_btn=0;
if($params->get("checkout_empty")!=0)
{
	$show_empty_btn = 1;
}
// helper object
$helper = new redhelper();
$helper->dbtocart();

$output_view 	= $params->get('cart_output', 'simple');
$session =& JFactory::getSession();
$cart = $session->get('cart');

if(count($cart)<=0 || $cart==""){
	$cart = array();
}
$idx  = 0;
if( (!array_key_exists("idx",$cart) || (array_key_exists("idx",$cart) && $cart['idx']<1)) && $params->get("use_cookies_value")==1)
{
	if($_COOKIE['redSHOPcart']!="")
	{
		$session->set('cart',unserialize(stripslashes($_COOKIE['redSHOPcart'])));
		$cart = $session->get('cart');
	}
}

if(!array_key_exists("quotation_id",$cart))
{
	if(isset($cart['idx']))
	{
		$idx = $cart['idx'];
	}
}
$product_quntity = 0;
for( $i=0 ; $i< $idx ; $i++ )
{
	$product_quntity += $cart[$i]['quantity'];
}
$count = $product_quntity;
$total = 0;
$shipping = 0;
if($idx){
	$total = $cart['mod_cart_total'];
	$shipping = $cart['shipping'];
	if($show_with_vat==0){
		$shippingVat =  $cart['shipping_vat'];
		$shipping = $shipping - $shippingVat;
	}

}
$session->set( 'cart',$cart) ;
require(JModuleHelper::getLayoutPath('mod_redshop_cart'));?>
